Ext.define('AM.view.TastcenterEmpForm',{
	extend: 'Ext.form.Panel',
	alias : 'widget.tastcenterEmpForm',
	layout : "form",
	items: [{
			   layout : "column",
			   border : false,
					 items: [{
							columnWidth :.25,
								layout : "form",
								border : false,
								labelWidth : 30,
							   	items: [{
							   			  xtype : "datefield",
							   			  fieldLabel: '	查询日期',
							   			  labelAlign :"right",
									      name: 'searchdate',
									      format:'Y-m-d'
								 }]		
						},{
							columnWidth :.25,
								layout : "form",
								border : false,
								labelWidth : 30,
							   	items: [{
										 xtype : "combobox",
									     allowBlank:false,
									     emptyText:'请选择科室',
										 selectOnFocus:true,
										 forceSelection: true,
										 queryMode: 'local',
										 labelAlign :"right",
										 fieldLabel: '科室',
										 name: 'searchdepartment',
//										 store :"TaskcenterDepartmentStore",
										 displayField: 'name',
			    						 valueField: 'id'
							   	}]
						}]
	 }],
	  buttons: [
	  			 {text: '导入工作量',
	  				 handler: function() {
					  		var myform1= new Ext.form.Panel({
							        layout : "form",
							        labelWidth : 65,
							        items: [{
									        	layout : "column",
									       		border : false,
									        	items: [{
												        	columnWidth :.40,
															layout : "form",
															border : false,
												   			items:[{
																       xtype : "combobox",
																       allowBlank:false,
																       emptyText:'请选择科室',
																       selectOnFocus:true,
																	   forceSelection: true,
																	   editable:false,
																	   queryMode: 'local',
																       labelAlign :"right",
																       fieldLabel: '选择科室',
																       name: 'department',
																       store :"TaskcenterDepartmentStore",
																       displayField: 'name',
							    									   valueField: 'id'
																   }]
									        		}]
									        	},{
									   		 	layout : "column",
											 	border : false,
													items: [{
															 columnWidth :.53,
													 		 layout : "form",
															 xtype: 'filefield',
													      	 name: 'upload',
													         fieldLabel: '工作量',
													         labelAlign :"right",
													         allowBlank: false,
													         buttonText: '请选择文件'
													}]
							   		 }]
						 })
						var win = new Ext.Window({
								title : "导入",
								width : 700,
								height : 300,
								frame:true,
								layout:'fit',
								items : [ myform1
											],
								buttons : [{
											text : "确定",
											handler : function() {
												win.getComponent(0).getForm().submit({
												      url : 'Supplyroom_uploadAndImportExcel',
												      waitMsg : "请稍后，正在保存。。。。",
													  success : function() {
															    Ext.Msg.alert('提示', '上传成功');
															    win.close();
															},
															failure : function() {
																Ext.Msg.alert('错误', '上传失败,请检查上传文件是否正确');
															}
															
					
														});
											}
										}, {
											text : "重置",
											handler : function() {
												win.getComponent(0).getForm().reset();
											}
										}, {
											text : "取消",
											handler : function() {
																win.close();
															
											}
										}]
							}).show();
							
				        }
	 			 },{
				        text: '计算奖金',
				        handler: function() {
				            var form = this.up('form').getForm();
				            var searchdateField =form.findField('searchdate');
				            var searchValue = searchdateField.getValue();
				            var depart =form.findField('searchdepartment');
				            var searchdepart = depart.getValue();
				            if (form.isValid()) {
				                form.submit({
				                	url: 'Supplyroom_listSupplyroombouns',
				                    success: function(form, action) {  
				                    	Ext.getCmp('taskCenterGrid').getStore().on('beforeload', function (store, options) {
                                     	  var new_params = {searchdate:Ext.util.Format.date(searchValue,'Y-m'),searchdepartment:searchdepart}
                                    	  Ext.apply(store.proxy.extraParams, new_params);
                                  	  });
                                     Ext.getCmp('taskCenterGrid').getStore().reload();
                                     
				                    },
				                    failure: function(form, action) {
				                   		 Ext.Msg.alert('计算失败', '请检查输入是否正确');
								   }	   
							  });
				            }
				        }
				 },{
				     text: '重新设置',
				     labelAlign :"right",
				     handler : function() {
								this.up('form').getForm().reset();
							}
			 }]
});
